class Solution
{
public:
    int maxValue(vector<vector<int> >& grid)
    {
        int dp[205][205];
        dp[1][1] = grid[0][0];
        for (int i = 0; i < grid.size(); i++)
            for (int j = 0; j < grid[0].size(); j++)
            {
                int x = i + 1, y = j + 1;
                dp[x][y] = max(dp[x - 1][y], dp[x][y - 1]) + grid[i][j];
            }
        return dp[grid.size()][grid[0].size()];
    }
};